<template>
  <div id="center">
    <div class="up">
      <div
        class="bg-color-black item"
        v-for="item in titleItem"
        :key="item.title" style="text-align: center">
        <p class="ml-3 colorBlue fw-b fs-xl" style="font-size: 20px;">{{ item.title }}</p>
        <div>
          <dv-digital-flop
            class="dv-dig-flop ml-1 mt-2 pl-3"
            :config="item.number"/>
        </div>
      </div>

    </div>
  </div>
</template>

<script>
import {getDay} from "@/axios/api";

export default {
  data() {
    return {
      titleItem: []
    }
  },mounted() {
    this.d();
  },methods:{
    async getDay(){
      let date = await getDay().then(res=>res.data)
      this.titleItem = [
        {
          title: '学生人数',
          number: {
            number: date[0],
            textAlign: 'center',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: '累计请假',
          number: {
            number: date[1],
            textAlign: 'center',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: '累计销假',
          number: {
            number: date[2],
            textAlign: 'center',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: '当日请假',
          number: {
            number: date[3],
            textAlign: 'center',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: '当日销假',
          number: {
            number: date[4],

            textAlign: 'center',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        }
      ]
    },
    d(){
// 设置好定时器，每1s调用一次
      this.timer=setInterval(()=>{
        this.getDay();
      },3000)
    },
    dget(){
      clearInterval(this.timer)
    }
  }
}
</script>

<style lang="scss" scoped>
#center {
  display: flex;
  flex-direction: column;
  .up {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    .item {
      border-radius: 6px;
      padding-top: 8px;
      margin-top: 13px;
      width: 150px;
      height: 70px;
      .dv-dig-flop {
        width: 150px;
        height: 30px;
      }
    }
  }
}
</style>
